package routes

import (
	"github.com/gin-gonic/gin"
	"oceanLearn/controllers"
	"oceanLearn/middleware"
)

func Routes(r *gin.Engine) *gin.Engine {
	r.Use(middleware.CORSMiddleware())
	r.POST("/api/v1/register", controllers.UserRegister)
	r.POST("api/v1/login", controllers.Login)
	r.GET("api/v1/userinfo", middleware.AuthMiddleware(),controllers.UserInfo)

	categoryRoutes := r.Group("/category")
	categoryController := controllers.NewCategoryController()

	categoryRoutes.POST("",categoryController.Create)
	categoryRoutes.PUT("/:id",categoryController.Update)
	categoryRoutes.GET("/:id",categoryController.Show)
	categoryRoutes.DELETE("/:id",categoryController.Delete)

	return r
}
